# ·模拟色子:随机生成3个1~6的数，·三个色子和在3~10=>小，11~18=>大
# ·用户在键盘输入猜”大”或”小“，一轮结果，给出结果
# ·可无限玩，直到用户输入exit，结束后，统计用户玩的次数,胜率·扩展:增加金豆，进场默认1000金豆，猜对赢100金豆，猜错输100金豆，金豆低于100不能继
# ·扩展:增加礼品  ：(如果胜率超过80% 赠送1000金豆）

import random

# 进场默认1000金豆
money = 1000

# 游戏次数
win_num = 0
to_num = 0

# 系统随机生成三个数
while money >= 100:

    nu1 = random.randint(1, 6)
    nu2 = random.randint(1, 6)
    nu3 = random.randint(1, 6)

    all_nu = nu1 + nu2 + nu3

    if 3 <= all_nu <= 10:
        answer = "大"
    elif 11 <= all_nu <= 18:
        answer = "小"

    guess = input("请输入你的答案，或选择退出")
    # 退出
    if guess == "exit":
        print("游戏结束！")
        break

    if guess == answer:
        print("恭喜你！猜对了")
        win_num = win_num + 1
        money = money + 100
        print("金豆+100，剩余金豆：{}".format(money))
    else:
        print("很遗憾，猜错了")
        money = money - 100
        print("金豆-100，剩余金豆：{}".format(money))
    to_num = to_num + 1

# 计算胜率
if win_num / to_num > 0.8 and to_num > 5:
    money = money + 1000
    print("太棒了！奖励1000金豆")

print(format("您剩余的金豆为 %i 的胜率为：%.2f, " %(money, win_num/to_num)))








